<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后台登录-X-admin2.0</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />


    <link rel="stylesheet" href="/css/xadmin.css">
    <script type="text/javascript" src="/js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="/js/vue.js"></script>


</head>
<body class="login-bg">

<div class="login" id="login">
    <div class="message">邮箱登录</div>
    <div id="darkbannerwrap"></div>


    <hr class="hr15">

    <form id="user" >
        <input name="email" placeholder="邮箱" v-model="user.email"  type="text" class="layui-input" >
        <hr class="hr15">
        <input name="code"   placeholder="验证码"  v-model="user.code" type="text">
        <hr class="hr15">
        <input value="发送验证码"  @click="sendCode()" style="width:100%;" type="button">
        <hr class="hr20" >
        <input value="邮箱登录"  @click="emailLogin()" style="width:100%;" type="button">
        <hr class="hr20" >
    </form>
</div>
<script>
    new Vue({
        el:"#login",
        data:{
            user:{
                email:"3287942773@qq.com",
                code:"",
            }
        },
        methods:{
            sendCode:function () {//发送验证码
                var self = this;
                $.ajax({
                    url:"/email/sendCode",
                    type:"post",
                    contentType:"application/x-www-form-urlencoded",
                    data:{"email":self.user.email},
                    dataType:"json",
                    success:function (data) {
                        console.log(data);
                        alert(data.info)
                    }


                })

            },
            emailLogin:function(){//邮箱登录
                var self = this;
                $.ajax({
                    url:"/email/emailLogin",
                    type:"post",
                    contentType:"application/x-www-form-urlencoded",
                    data:{"code":self.user.code},
                    dataType:"json",
                    success:function (data) {
                        console.log(data);
                        alert(data.info)
                        if (data.info == "邮箱登录成功") {
                            window.location.href = "/user/indexPage";
                        }

                    }
                })
            }
        }

    })
</script>
</body>
</html>